package com.demo.service.blank;

import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.delegate.BpmnError;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;

/**
 * 验证结果
 * @author K
 */
@Slf4j
@Component(value = "verifyTransferDelegate")
public class VerifyTransferDelegate implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution) {
        //从执行流中获取变量
        int input = execution.getVariable("input", Integer.class);
        int output = execution.getVariable("output", Integer.class);

        if (input == output) {
            log.info("转账成功");
        } else {
            log.info("转账失败，抛出错误");
            throw new BpmnError("transferError");
        }
    }
}
